<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->

    <!-- table区域-begin -->
    <a-input  v-model="tishi" style="background: transparent; border: 0px;color: #000c17" disabled></a-input>
    <br><br>
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"

        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>




      </a-table>


  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import ATextarea from 'ant-design-vue/es/input/TextArea'
  import { getAction, httpAction, postAction } from '../../../api/manage'
  import { filterObj } from '../../../utils/util'




  export default {
    name: 'FdmTmrRecipemandes',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      ATextarea
    },
    data () {
      return {

        description: '饲喂配方管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'班次',
            align:"center",
            sorter:true,
            dataIndex: 'banci'
          },
          {
            title:'饲料名称',
            align:"center",
            sorter:true,
            dataIndex: 'feedname'
          },
          {
            title:'标准重量',
            align:"center",
            sorter:true,
            dataIndex: 'amount'
          },
          {
            title:'实际饲喂',
            align:"center",

            dataIndex: 'workfeed'
          },

          {
            title:'误差',
            align:"center",
            dataIndex: 'error'
          },
          {
            title:'执行情况',
            align:"center",
            dataIndex: 'situation'
          },

          {
            title:'操作人',
            align:"center",
            dataIndex: 'admin'
          },

        ],
        tishi:"",
        url: {
          list: "/recipemandes/fdmTmrRecipemandes/list",
          edit: "/recipemandes/fdmTmrRecipemandes/edit",
        },
        superFieldList:[],
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {

    },
    methods: {
      initDictConfig() {
      },

      recipemandes(arg,a) {

        if(!this.url.list){
          this.$message.error("请设置url.list属性!")
          return
        }
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {

          this.ipagination.current = 1;
        }
        var params = this.getQueryParams(a);//查询条件

        this.loading = true;
        getAction(this.url.list, params).then((res) => {
          if (res.success) {

            //update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
            this.dataSource = res.result.records||res.result;
            if(res.result.total)
            {
              this.ipagination.total = res.result.total;
            }else{
              this.ipagination.total = 0;
            }
            //update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          }
          if(res.code===510){
            this.$message.warning(res.message)
          }
          this.loading = false;
        })
      },
      getQueryParams(a) {
        //获取查询条件
        let sqp = {}
        if(this.superQueryParams){
          sqp['superQueryParams']=encodeURI(this.superQueryParams)
          sqp['superQueryMatchType'] = this.superQueryMatchType
        }
        this.queryParam.orderid=a;
        var param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters);
        console.log(this.queryParam)
        param.field = this.getQueryField();
        param.pageNo = this.ipagination.current;
        param.pageSize = this.ipagination.pageSize;
        return filterObj(param);
      },
      getQueryField() {
        //TODO 字段权限控制
        var str = "id,";
        this.columns.forEach(function (value) {
          str += "," + value.dataIndex;
        });
        return str;
      },


      des(record){

        // var a = Object.assign({}, record);
       // var b = '牛舍类型:' + a.cowshename + '; 配方类型:' + a.recipename + '; 当前存栏:' + a.cunlan + '; 饲喂总量:' + a.feedall;
       //  this.tishi = '牛舍类型:' + record.cowshename + '; 配方类型:' + record.recipename + '; 当前存栏:' + record.cunlan + '; 饲喂总量:' + record.feedall;
       // console.log(b.toString());
       //  this.tishi=b.toString();

         this.tishi = '牛舍类型:' + record.cowshename + '; 配方类型:' + record.recipename + '; 当前存栏:' + record.cunlan + '; 饲喂总量:' + record.feedall;
        console.log(this.tishi);
        postAction(this.url.edit,record).then((res) =>{
          console.log(record.id);
           var a=record.id;
           this.recipemandes(1,a);
            })


      },
      getSuperFieldList() {
        let fieldList = [];
        fieldList.push({ type: 'string', value: '班次', text: '班次', dictCode: '' })
        fieldList.push({ type: 'string', value: 'feedname', text: '饲料名称', dictCode: '' })
        fieldList.push({ type: 'double', value: 'amount', text: '标准重量', dictCode: '' })
        fieldList.push({ type: 'double', value: 'workfeed', text: '实际饲喂', dictCode: '' })
        fieldList.push({ type: 'double', value: 'error', text: '误差', dictCode: '' })
        fieldList.push({ type: 'string', value: 'situation', text: '执行情况', dictCode: '' })
        fieldList.push({ type: 'string', value: 'admin', text: '操作人', dictCode: '' })
        this.superFieldList = fieldList
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>